import java.util.Scanner;

public class p1980 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            String s = String.valueOf(i);
            for (int j = 0; j < s.length(); j++) {
                if (s.charAt(j) == (char) (x + '0')) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

